$(document).on('pageinit', function(){

    $('#registration_form').validate({
        rules: {
            current_password: {
                required: true,
                maxlength: 50
            },
            new_password: {
                required: true,
                minlength: 4
            },
            new_password_repeat:{
                required: true,
                equalTo: "#input_new_password"
            }
        },
        messages: {
            current_password: {
                required: "Your current password is required.",
                maxlength: "Can't be longer then 50 characters."
            },
            new_password: {
                required: "New password is required.",
                minlength: "Your password has to be at least 4 characters."
            },
            new_password_repeat:{
                required: "Please repeat the new password.",
                equalTo: "The passwords have to match!"
            }
        },
        errorPlacement: function (error, element) {
            if (element.is("input") && !element.is('input[type="hidden"]'))
                error.insertAfter(element.parent());
            else
                error.insertAfter(element);
        }
    });

});